<template>
	<comRoot>
		<template #page>
			<comDetailNavigateBack title="赏品详情"/>
			
			<image v-if="commonConfigs && commonConfigs.domainFrontFileLink" :src="`${commonConfigs.domainFrontFileLink}/files/images/page-bg.png`" class="bg" />
			
			<view v-if="shopDetail && shopDetail.reward_item_name" class="relative info-data" :style="{'height':`calc(100vh - ${commonNavHeight} )`}">
				<view class="info-cover margin-auto flex-all-center relative" >
					<image v-if="commonConfigs && commonConfigs.domainFrontFileLink" :src="`${commonConfigs.domainFrontFileLink}/files/images/details/info-box-bg.png`" class="bg" />
					
					<comPlaceImage
						placeImageClass="flex-all-center"
						class="info-cover-img"
						:lazyLoad="true"
						:src="shopDetail.reward_item_cover"
						mode=""
						:isLoadingImgOriginSize="true"
						:isOverHide="false"
						style="min-width: 606rpx; height: 606rpx; margin: auto; display: block;"
						></comPlaceImage>
				</view>
				
				<view class="info-name font-hanserif-bold">{{ shopDetail.reward_item_name }}</view>

				<view class="info-lever-img relative flex-all-center" v-if="shopDetail.reward_item_type">
					<image
						v-if="commonConfigs && commonConfigs.domainFrontFileLink && shopDetail.reward_item_type.toLowerCase() === 'hot'"
						:src="`${commonConfigs.domainFrontFileLink}/files/images/abounty/hot-icon.png`"
						mode="heightFix"
					></image>
					<image
						v-else-if="commonConfigs && commonConfigs.domainFrontFileLink && shopDetail.reward_item_type.toLowerCase() === 'cool'"
						:src="`${commonConfigs.domainFrontFileLink}/files/images/abounty/cool-icon.png`"
						mode="heightFix"
					></image>
					<image
						v-else-if="commonConfigs && commonConfigs.domainFrontFileLink && shopDetail.reward_item_type === '全局'"
						:src="`${commonConfigs.domainFrontFileLink}/files/images/abounty/all-icon.png`"
						mode="heightFix"
					></image>
					<image
						v-else-if="commonConfigs && commonConfigs.domainFrontFileLink && shopDetail.reward_item_type.toLowerCase() === 'first'"
						:src="`${commonConfigs.domainFrontFileLink}/files/images/abounty/first-icon.png`"
						mode="heightFix"
					></image>
					<image
						v-else-if="commonConfigs && commonConfigs.domainFrontFileLink && shopDetail.reward_item_type.toLowerCase() === 'last'"
						:src="`${commonConfigs.domainFrontFileLink}/files/images/abounty/last-icon.png`"
						mode="heightFix"
					></image>
					<image
						v-else-if="commonConfigs && commonConfigs.domainFrontFileLink && shopDetail.reward_item_type === '夺宝'"
						:src="`${commonConfigs.domainFrontFileLink}/files/images/abounty/treasure-icon.png`"
						mode="heightFix"
					></image>
					<image
						v-else-if="commonConfigs && commonConfigs.domainFrontFileLink && shopDetail.reward_item_type === '叠叠'"
						:src="`${commonConfigs.domainFrontFileLink}/files/images/abounty/stacking-icon.png`"
						mode="heightFix"
					></image>
					<image
						v-else-if="commonConfigs && commonConfigs.domainFrontFileLink && shopDetail.reward_item_type === '冲冲'"
						:src="`${commonConfigs.domainFrontFileLink}/files/images/abounty/flush-icon.png`"
						mode="heightFix"
					></image>
					<!-- 普通赏 -->
					<image
						v-else-if="commonConfigs && commonConfigs.domainFrontFileLink && shopDetail.reward_item_type === '普通'"
						:src="`${commonConfigs.domainFrontFileLink}/files/images/abounty/ordinary-icon.png`"
						mode="heightFix"
					></image>
					<!-- 等级 -->
					<!-- <image v-else 
					:src="`${commonConfigs.domainFrontFileLink}/files/images/common/level/level-` + (shopDetail.reward_item_type && shopDetail.reward_item_type.toLowerCase()) + '.png'"
					mode="heightFix"></image> -->
					
				</view>
				
				<view class="info-detail margin-auto relative">
					<view class="relative">
						<view class="detail-box flex-justify-content-between font-hanserif-bold">
							<view class="detail-title flex-all-center">发货说明</view>
							<view class="detail-data" v-html="ruleTxt"></view>
						</view>
						<view class="detail-box flex-justify-content-between font-hanserif-bold" v-if="type === 'infinite' || type === 'boxReward'">
							<view class="detail-title flex-all-center">物品说明</view>
							<view class="detail-data">{{ shopDetail.description || '-' }}</view>
						</view>
						<template v-if="type === 'all' || type === 'aplus' || type === 'lockbox'">
							<view class="detail-box flex-justify-content-between font-hanserif-bold">
								<view class="detail-title flex-all-center">实时概率</view>
								<view class="detail-data flex-all-center" v-if="shopDetail.is_give === 1">赠品</view>
								<view class="detail-data flex-all-center" v-else>{{ shopDetail.reward_rate || '-' }}</view>
							</view>
							<view class="detail-box flex-justify-content-between font-hanserif-bold">
								<view class="detail-title flex-all-center">概率说明</view>
								<view class="detail-data" v-if="probabilityExplan" v-html="probabilityExplan"></view>
								<view class="detail-data" v-else>-</view>
							</view>
						</template>
						<template v-if="type === 'pk' || type === 'treasure'">
							<view class="detail-box flex-justify-content-between font-hanserif-bold">
								<view class="detail-title flex-all-center">实时概率</view>
								<view class="detail-data flex-all-center" v-if="shopDetail.is_give === 1">赠品</view>
								<view class="detail-data flex-all-center" v-else>{{ shopDetail.reward_rate || '-' }}</view>
							</view>
							<view class="detail-box flex-justify-content-between font-hanserif-bold">
								<view class="detail-title flex-all-center">物品说明</view>
								<view class="detail-data flex-all-center">{{ shopDetail.item_desc || '-' }}</view>
							</view>
						</template>
						<view class="detail-box flex-justify-content-between font-hanserif-bold">
							<view class="detail-title flex-all-center">参考价</view>
							<!-- #ifdef APP-PLUS -->
							<view class="detail-data flex-all-center">{{ shopDetail.reference_price ? '¥' + shopDetail.reference_price : '-' }}</view>
							<!-- #endif -->
							<!-- #ifdef MP-WEIXIN -->
							<view class="detail-data flex-all-center" v-if="userInfo.show_recovery">{{ shopDetail.reference_price ? '¥' + shopDetail.reference_price : '-' }}</view>
							<view class="detail-data flex-all-center" v-else>{{ shopDetail.reward_price_1 ? '¥' + shopDetail.reward_price_1 : '-' }}</view>
							<!-- #endif -->
						</view>
						<view class="detail-box flex-justify-content-between font-hanserif-bold">
							<view class="detail-title flex-all-center">品牌</view>
							<view class="detail-data flex-all-center">{{ shopDetail.brand || '-' }}</view>
						</view>
						<view class="detail-box flex-justify-content-between font-hanserif-bold">
							<view class="detail-title flex-all-center">作品</view>
							<view class="detail-data flex-all-center">{{ shopDetail.opus || '-' }}</view>
						</view>
						<view class="detail-box flex-justify-content-between font-hanserif-bold">
							<view class="detail-title flex-all-center">备注</view>
							<view class="detail-data flex-all-center">{{ shopDetail.remarks || '-' }}</view>
						</view>
					</view>
				</view>
			</view>
		</template>
	</comRoot>
</template>

<script>
	import store from '@/store';
	
	import { getContentHomeApi } from '@/setupproject/INTERFACE';
	
	export default {
		name: 'goodDetailPage',
		data() {
			return {
				ruleTxt: '',
				probabilityExplan: '',
				type: '',
				shopDetail: {},
			}
		},
		computed: {
			userInfo() {
				return store.getters.userInfo;
			},
			commonNavHeight() {
				return store.getters.commonNavHeight + 'px';
			},
			commonConfigs() {
				return store.getters.commonConfigs || {};
			},
		},
		async onLoad({type}) {
			this.ruleTxt = await this.ruleContentGetFun(41);
			
			// infinite 无限赏  all 全局赏  pk PK赏
			// treasure 夺宝赏 aplus 一番赏
			this.type = type;
		   
			if(['infinite', 'boxReward'].indexOf(this.type) !== -1) {
				this.shopDetail = this.$store.getters.commonInfiniteDetail;
			} else if (['all', 'pk', 'treasure', 'aplus', 'lockbox'].indexOf(this.type) !== -1) {
				this.shopDetail = this.$store.getters.commonGlaobalDetail;
			} else {
				this.shopDetail = this.$store.getters.commonGlaobalDetail;
			}
			
			if(['all', 'pk', 'treasure', 'aplus', 'lockbox'].indexOf(this.type) !== -1) {
				this.probabilityExplan = await this.ruleContentGetFun(44);
			}
		},
		methods: {
			async ruleContentGetFun(type) {
				let ruleTxt = '';
				await getContentHomeApi({
					type
				}).then((res) => {
					ruleTxt = res.data.content;
				});
				return ruleTxt;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.info-data {
		font-size: 38rpx;
		color: #fff;
		overflow-y: auto;
		padding-bottom: 70rpx;
		.info-cover {
			width: 710rpx;
			height: 710rpx;
			overflow: hidden;
			.info-cover-img {
				max-width: 606rpx;
				height: 606rpx;
				margin: auto;
			}
		}
		.info-name {
			margin: 18rpx 0;
			padding: 0 36rpx;
			text-align: center;
			font-size: 36rpx;
			color: #FFFFFF;
		}
		
		.info-lever-img {
			image {
				max-width: 200rpx;
				height: 48rpx;
			}
		}
		
		.info-detail {
			width: 708rpx;
			border: 2rpx solid #CEDAFF;
			border-radius: 16rpx;
			.detail-box {
				font-size: 28rpx;
				border-bottom: 2rpx solid #CEDAFF;
				.detail-title {
					width: 160rpx;
					color: #FFFFFF;
					font-weight: bold;
					border-right: 2rpx solid #CEDAFF;
				}
				.detail-data {
					color: #FFFFFF;
					width: 540rpx;
					font-size: 24;
					min-height: 88rpx;
					padding: 12rpx 8rpx;
					text-align: center;
				}
				&:last-child {
					border-bottom: none;
				}
			}
			
		}
	}
</style>